uniform vec4 env_screenSize;
uniform vec3 lightPositionOnScreen;
uniform vec2 deltaSun;

uniform sampler2D firstPass;
uniform sampler2D screen;

const int NUM_SAMPLES = 80;

void main(){

	vec2 currentFrag = vec2(gl_FragCoord.x/env_screenSize.x, gl_FragCoord.y/env_screenSize.y);
	vec4 ori = texture2D(screen, currentFrag );

	vec2 deltaTextCoord = ( vec2(gl_FragCoord.x/env_screenSize.x, gl_FragCoord.y/env_screenSize.y)
			- vec2( ((lightPositionOnScreen.x)/env_screenSize.x), (lightPositionOnScreen.y)/env_screenSize.y))
			* (1.0 / float(NUM_SAMPLES));

	vec2 textCoo = currentFrag;
	vec4 result = vec4(0.0, 0.0, 0.0, 0.0);
	vec4 sample;

	for (int i = 0; i < NUM_SAMPLES; i++){
		textCoo -= deltaTextCoord;
		result += texture2D(firstPass, textCoo) * (0.5 + float(NUM_SAMPLES-i)/float(2*NUM_SAMPLES));
	}

	gl_FragColor = ori + result/float(NUM_SAMPLES);// * transparent;*/

}
